import requests
from bs4 import BeautifulSoup

def webhook_to_webhook(source_webhook_url, target_webhook_url):
    # 发送请求到源Webhook URL并获取响应
    response = requests.post(source_webhook_url)
    if response.status_code == 200:
        # 使用BeautifulSoup解析响应的HTML内容
        soup = BeautifulSoup(response.text, 'html.parser')
        # 在解析后的HTML中找到需要的数据，这里假设需要找到一个元素的文本内容
        data = soup.find('div', {'class': 'my-class'}).text
        
        # 将解析得到的数据发送到目标Webhook URL
        requests.post(target_webhook_url, data={'payload': data})
    else:
        print(f'请求失败，状态码：{response.status_code}')

def send_message_to_feishu(webhook_url, message):
    # 发送请求到飞书Webhook URL并传递消息
    requests.post(webhook_url, data={'msg': message})

# 源Webhook URL
source_webhook_url = 'https://example.com/source-webhook'

# 目标Webhook URL
target_webhook_url = 'https://example.com/target-webhook'

# 飞书Webhook URL
feishu_webhook_url = 'https://open.feishu.cn/open-apis/bot/v2/hook/XXXXXXXXXXXXXXXXXXXX'

# 从源Webhook获取数据，并发送到目标Webhook
webhook_to_webhook(source_webhook_url, target_webhook_url)

# 从目标Webhook获取数据，并发送到飞书
message = 'Hello from Python!'
send_message_to_feishu(feishu_webhook_url, message)